<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\Fang;
use Illuminate\Http\Request;
use App\Models\Node;
class IndexController extends Controller
{
    //后台首页显示
    public function index()
    {
        $auth = session('admin.auth');
        //读取菜单
        //$menuData = Node::where('is_menu','1')->get();
        $menuData = (new Node())->treeData($auth);
        //指定模板视图
        return view('admin.index.index',compact('menuData'));
    }
    //欢迎页面
    public function welcome()
    {
        $data = (new Fang())->fangStatusCount();
        return view('admin.index.welcome',$data);
    }
    //退出
    public function logout()
    {
        //用户退出，清空session
        auth()->logout();
        //跳转，带提示 闪存 session
        return redirect(route('admin.login'))->with('success','请重新登录');
    }
}
